﻿package mortal.game.view.copy.sunbathCopy.view
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.copy.sunbathCopy.*;
    import mortal.game.view.vip.*;
    import mortal.game.view.vip.panel.*;
    import mortal.mvc.interfaces.*;

    public class SunBathPassWin extends ResultBaseWindow
    {
        protected var _expItem:BaseItem;
        protected var _valItem:BaseItem;
        protected var _passTitle:GBitmap;
        protected var _title2:GBitmap;
        protected var _expDes:GBitmap;
        protected var _valDes:GBitmap;
        protected var _exp:BitmapNumberText;
        protected var _val:BitmapNumberText;
        protected var _expAddTxt:GTextFiled;
        protected var _expVipTip:VipOpenTipsPanel;
        protected var _manoAddTxt:GTextFiled;
        protected var _manoVipTip:VipOpenTipsPanel;
        private var _vipType:int = 38;
        private static var _instance:SunBathPassWin;

        public function SunBathPassWin(param1:ILayer = null)
        {
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            LoaderHelp.addResCallBack(ResFileConst.sunbathCopy, this.onResLoad);
            return;
        }// end function

        private function onResLoad() : void
        {
            this._expItem = UIFactory.getUICompoment(BaseItem);
            this._expItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._valItem = UIFactory.getUICompoment(BaseItem);
            this._valItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._passTitle = UIFactory.gBitmap(ImagesConst.SunbathPassTitle, 230, -37, this);
            this._title2 = UIFactory.gBitmap(ImagesConst.SunbathPassTitle2, 256, 43, this);
            this._expDes = UIFactory.gBitmap(ImagesConst.SunbathPassExpDes, 173, 97, this);
            this._valDes = UIFactory.gBitmap(ImagesConst.SunbathPassValDes, 173, 172, this);
            this._exp = UIFactory.bitmapNumberText(331, 98, "EquipmentTipsNumber.png", 16, 16, -5, this, 13, 0);
            this._exp.text = "+123465798";
            this._val = UIFactory.bitmapNumberText(331, 175, "EquipmentTipsNumber.png", 16, 16, -5, this, 13, 0);
            this._val.text = "123";
            this._expItem.x = 251;
            this._expItem.y = 85;
            var _loc_1:Boolean = false;
            this._expItem.isDropAble = false;
            this._expItem.isDragAble = _loc_1;
            this.addChild(this._expItem);
            this._expItem.itemCode = 180011015;
            this._valItem.x = 251;
            this._valItem.y = 160;
            this._valItem.itemCode = 180141004;
            var _loc_1:Boolean = false;
            this._valItem.isDropAble = false;
            this._valItem.isDragAble = _loc_1;
            this.addChild(this._valItem);
            this._expAddTxt = UIFactory.gTextField("[VIP+123456]", 436, 92, 100, 25, this, GlobalStyle.textFormatLv.setSize(13).setBold(true));
            this._manoAddTxt = UIFactory.gTextField("[VIP+123456]", 437, 169, 100, 25, this, GlobalStyle.textFormatLv.setSize(13).setBold(true));
            this._expVipTip = UIFactory.getUICompoment(VipOpenTipsPanel, 332, 123, this);
            this._expVipTip.valueType = VipOpenTipsPanel.percentValue;
            this._expVipTip.resetLevelTextPos(61, 1, 33, 1);
            this._expVipTip.resetValueTextPos(155, 1, 97, 1);
            this._expVipTip.resetTipsTextPos(0, 0, 0, 0);
            this._expVipTip.bgUrl = "";
            this._expVipTip.vipType = 44;
            this._manoVipTip = UIFactory.getUICompoment(VipOpenTipsPanel, 332, 197, this);
            this._manoVipTip.valueType = VipOpenTipsPanel.percentValue;
            this._manoVipTip.resetLevelTextPos(61, 1, 33, 1);
            this._manoVipTip.resetValueTextPos(155, 1, 97, 1);
            this._manoVipTip.resetTipsTextPos(0, 0, 0, 0);
            this._manoVipTip.bgUrl = "";
            this._manoVipTip.vipType = 45;
            this.updateReward();
            setContentBgSize(376, 172);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._expItem = null;
            this._valItem = null;
            this._passTitle = null;
            this._title2 = null;
            this._expDes = null;
            this._valDes = null;
            this._exp = null;
            this._val = null;
            this._expAddTxt = null;
            this._manoAddTxt = null;
            this._expVipTip = null;
            this._manoVipTip = null;
            return;
        }// end function

        override protected function addCloseButton() : void
        {
            _closeBtn = UIFactory.gLoadedButton(ImagesConst.Close_upSkin, 0, 0, 22, 20, null);
            _closeBtn.focusEnabled = true;
            _closeBtn.name = "Window_Btn_Close";
            _closeBtn.configEventListener(MouseEvent.CLICK, closeBtnClickHandler);
            _contentTopOf3DSprite.addChild(_closeBtn);
            return;
        }// end function

        override protected function updateBtnSize() : void
        {
            if (_closeBtn)
            {
                _closeBtn.x = this.width - _closeBtn.width - 45;
                _closeBtn.y = 5;
            }
            return;
        }// end function

        override protected function enterBtnClickHandler(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

        public function updateReward() : void
        {
            var _loc_1:* = SunbathUtil.getPassWinReward();
            if (_loc_1 == null || _loc_1.length < 2)
            {
                return;
            }
            this._exp.text = "+" + _loc_1[0];
            this._val.text = "+" + _loc_1[1];
            this.updateVip(_loc_1);
            return;
        }// end function

        private function updateVip(param1:Array) : void
        {
            var _loc_2:int = 0;
            var _loc_3:Number = NaN;
            if (VipUtil.isVipReachLevelByType(this._vipType))
            {
                var _loc_4:Boolean = true;
                this._manoAddTxt.visible = true;
                this._expAddTxt.visible = _loc_4;
                _loc_2 = 0;
                _loc_3 = VipUtil.getCurValueByType(this._vipType);
                _loc_2 = param1[0];
                _loc_2 = _loc_2 * _loc_3 / 100;
                this._expAddTxt.text = "[VIP+" + _loc_2 + "]";
                this._expAddTxt.x = this._exp.x + this._exp.width + 2;
                _loc_2 = param1[1];
                _loc_2 = _loc_2 * _loc_3 / 100;
                this._manoAddTxt.text = "[VIP+" + _loc_2 + "]";
            }
            else
            {
                var _loc_4:Boolean = false;
                this._manoAddTxt.visible = false;
                this._expAddTxt.visible = _loc_4;
            }
            return;
        }// end function

        public static function get instance() : SunBathPassWin
        {
            if (_instance == null)
            {
                _instance = new SunBathPassWin;
            }
            return _instance;
        }// end function

    }
}
